package com.ssm.springboot.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
public class KaptchaConfig {

    @Bean
    public DefaultKaptcha defaultKaptcha(){
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        Properties properties = new Properties();
        //1.边框
        properties.setProperty("kaptcha.border","no");
        //2.生成验证码的位数
        properties.setProperty("kaptcha.textproducer.char.length","4");
        //3.验证码的范围
        properties.setProperty("kaptcha.textproducer.char.string","0123456789");
        //4.验证码的颜色
        properties.setProperty("kaptcha.background.clear.to","211,229,237");

        Config config=new Config(properties);
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;

    }
}
